import DKVui from "dk-vui"
import 'dk-vui/dist/style.css'
import tableFormApi from '@/api/tableForm'
import { warehouse, supplier, platforms, warehouseList, role } from '@/api/public'
import request from '@/utils/request'
import { upload } from '@/api/public'

const get = (url, params) => {
  return request({
    url,
    method: 'get',
    params
  })
}

export default function (app) {
  app.use(DKVui)
  DKVui.setup({
    table: {
      scrollHideForm: true,
      formConfig: {
        proxy: {
          mainKey: 'sc_id', // 主键
          query: ({ model_type }) => tableFormApi.query({ model_type }),
          // model_type 类型/ name 保存名称 / sc_id 主键 / conditions保存条件
          save: ({ model_type, name, sc_id, conditions }) => tableFormApi.save({ model_type, name, sc_id, conditions }),
          remove: ({ sc_id }) => tableFormApi.remove({ sc_id })
        }
      }
    },
    select: {
      types: {
        warehouse, // 仓库
        warehouseList, // 仓库平台
        supplier, // 供应商
        platforms, // 平台
        role, // 角色
      }
    },
    batchInput: {
      rows: 500
    },
    upload: {
      upload,
      size: 144
    }
  })
}